/*Source

Problem Id:2684  User Id:Latex 
Memory:68K  Time:0MS
Language:G++  Result:Accepted

Source 
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct 
{
	int n;
	int dian[60][2];
	int order[60];
	int rorder[60];
	int turn[60];
	int rturn[60];
	int len[60];
}Tnode;
Tnode model, model2, comp, comp2;

int n;
int edge;


void readmodel()
{
	int i, x, y;
	scanf("%d", &edge);
	model.n = edge;
	for (i=1; i<=edge; ++i)
	{
		scanf("%d%d", &model.dian[i][0], &model.dian[i][1]);
		model2.dian[edge-i+1][0] = model.dian[i][0];
		model2.dian[edge-i+1][1] = model.dian[i][1];
	}
	
	for (i=1; i<edge; ++i)
	{
		x = model.dian[i+1][0] - model.dian[i][0];
		y = model.dian[i+1][1] - model.dian[i][1];
		model.len[i] = abs(x+y);
		if (x==0)
		{
			if (y>0) model.order[i] = 0;
			else model.order[i] = 2;
		} 
		else
		{
			if (x>0) model.order[i] = 1;
			else model.order[i] = 3;
		}
	}
	for (i=1; i<edge-1; ++i)
	{
		if (model.order[i] == model.order[i+1]) model.turn[i] = 0;
		else if (model.order[i+1]-model.order[i] == 1 || model.order[i+1]-model.order[i] == -3) model.turn[i] = -1;
		else if (model.order[i+1]-model.order[i] == -1 || model.order[i+1]-model.order[i] == 3) model.turn[i] = 1;
		else model.turn[i] = 2;
	}
	// do model2
	model2.n = edge;
	for (i=1; i<edge; ++i)
	{
		x = model2.dian[i+1][0] - model2.dian[i][0];
		y = model2.dian[i+1][1] - model2.dian[i][1];
		model2.len[i] = abs(x+y);
		if (x==0)
		{
			if (y>0) model2.order[i] = 0;
			else model2.order[i] = 2;
		} 
		else
		{
			if (x>0) model2.order[i] = 1;
			else model2.order[i] = 3;
		}
	}
	for (i=1; i<edge-1; ++i)
	{
		if (model2.order[i] == model2.order[i+1]) model2.turn[i] = 0;
		else if (model2.order[i+1]-model2.order[i] == 1 || model2.order[i+1]-model2.order[i] == -3) model2.turn[i] = -1;
		else if (model2.order[i+1]-model2.order[i] == -1 || model2.order[i+1]-model2.order[i] == 3) model2.turn[i] = 1;
		else model2.turn[i] = 2;
	}
			
}

void readcomp()
{
	int i, x, y;
	scanf("%d", &edge);
	comp.n = edge;
	for (i=1; i<=edge; ++i)
	{
		scanf("%d%d", &comp.dian[i][0], &comp.dian[i][1]);
		model2.dian[edge-i+1][0] = comp.dian[i][0];
		model2.dian[edge-i+1][1] = comp.dian[i][1];
	}
	
	for (i=1; i<edge; ++i)
	{
		x = comp.dian[i+1][0] - comp.dian[i][0];
		y = comp.dian[i+1][1] - comp.dian[i][1];
		comp.len[i] = abs(x+y);
		if (x==0)
		{
			if (y>0) comp.order[i] = 0;
			else comp.order[i] = 2;
		} 
		else
		{
			if (x>0) comp.order[i] = 1;
			else comp.order[i] = 3;
		}
	}
	for (i=1; i<edge-1; ++i)
	{
		if (comp.order[i] == comp.order[i+1]) comp.turn[i] = 0;
		else if (comp.order[i+1]-comp.order[i] == 1 || comp.order[i+1]-comp.order[i] == -3) comp.turn[i] = -1;
		else if (comp.order[i+1]-comp.order[i] == -1 || comp.order[i+1]-comp.order[i] == 3) comp.turn[i] = 1;
		else comp.turn[i] = 2;
	}	
}


bool cancomp()
{
	int i, n;
	bool yes;
	yes = false;
	if (comp.n != model.n) return false;
	n = comp.n;
	for (i=1; i<n; ++i)
	{
		if (model.len[i] != comp.len[i]) return false;
	}
	for (i=1; i<n-1; ++i)
	{
		if (model.turn[i] != comp.turn[i]) return false;
	}
	return true;
}

bool cancomp2()
{
	int i, n;
	bool yes;
	yes = false;
	if (comp.n != model2.n) return false;
	n = comp.n;
	for (i=1; i<n; ++i)
	{
		if (model2.len[i] != comp.len[i]) return false;
	}
	for (i=1; i<n-1; ++i)
	{
		if (model2.turn[i] != comp.turn[i]) return false;
	}
	return true;
}

int main()
{
	int i;
	
//	freopen("b.in","r",stdin);
//	freopen("b.out", "w", stdout);
	
	while (1)
	{
		scanf("%d", &n);
		if (!n) break;
		readmodel();
		for (i=1; i<=n; ++i)
		{
			readcomp();
			if ( cancomp() || cancomp2() ) printf("%d\n", i);
		}
		printf("+++++\n");
				
		
	}// end of while 
	
	
	
	return 0;	
}


